Skip to content

fix(init): migrate legacy Antigravity rules on install and uninstall (#4317) - #4335

Open
Aayushyaash wants to merge 2 commits into
rtk-ai:developfrom
Aayushyaash:fix/antigravity-legacy-rules-cleanup
Open

Aayushyaash wants to merge 2 commits into
rtk-ai:developfrom
Aayushyaash:fix/antigravity-legacy-rules-cleanup

Conversation

@Aayushyaash

@Aayushyaash Aayushyaash commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4317

Description

This is a follow-up to the native Antigravity plugin support added in #3711.

Before #3711, rtk init --agent antigravity created .agents/rules/antigravity-rtk-rules.md. After moving to the native plugin, that legacy file could still be left behind in existing workspaces. This could cause duplicate awareness text after an upgrade, and the file would remain after uninstall.

This PR cleans up that legacy file during the Antigravity install/uninstall flow without touching user-owned content.

What changed

  • Remove the legacy file when it contains only RTK awareness text.
  • If RTK awareness was appended to existing user content, remove only RTK's appended text and preserve the user content byte-for-byte.
  • Leave unrelated/foreign files untouched and silent.
  • Clean up the workspace legacy file when running rtk init -g --agent antigravity from inside a workspace.
  • Keep --dry-run non-mutating.
  • Run the cleanup during install and uninstall.

Tests

Added unit and process-level tests covering:

  • Legacy file removal.
  • Legacy suffix removal while preserving user content.
  • Foreign file preservation.
  • Install and uninstall.
  • Global -g install from a workspace.
  • Dry-run behavior.

Also verified the full lifecycle manually against the built rtk binary.

Verification

  • cargo fmt --all --check ✓
  • cargo clippy --all-targets -- -D warnings ✓
  • cargo test --bin rtk test_antigravity ✓
  • cargo test --test antigravity_hook_test ✓

@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

This PR migrates legacy Antigravity rules files (.agents/rules/antigravity-rtk-rules.md) left behind by earlier RTK versions when installing or uninstalling the native Antigravity plugin. It removes the legacy file if it contains only RTK-generated content, strips only the RTK-appended suffix while preserving user content when both are present, and leaves unrelated files untouched, with dry-run support.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4317


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Migrate the legacy .agents/rules/antigravity-rtk-rules.md during
Antigravity lifecycle operations:
- Remove it when it contains only RTK's legacy awareness text.
- Remove only RTK's appended awareness text when the file also contains
  user content, preserving the user content byte-for-byte.
- Leave unrelated or foreign files untouched and silent.
- Handle install, uninstall, and -g install from within a workspace.
- Keep --dry-run non-mutating.
- Add unit and process-level integration tests for each case.
@Aayushyaash
Aayushyaash force-pushed the fix/antigravity-legacy-rules-cleanup branch from 9e4ec73 to 69a04d6 Compare September 28, 2026 14:14
@Aayushyaash

Copy link
Copy Markdown
Contributor Author

@KuSh @aeppling
This PR is ready for review! Whenever you have a moment, I’d appreciate you taking a look. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk init --agent antigravity leaves the rules file written by earlier releases in place, on install and on uninstall

1 participant